﻿using DBServer.Selenium.Extenium.Path;
using Selenium;

namespace DBServer.Selenium.Extenium.Fixtures
{
    public class ExtApplicationFixture
    {
        public ISelenium Driver;

        public ExtApplicationFixture()
        {
            
        }

        public ExtApplicationFixture(string hostName, string hostPage, string seleniumHost, int seleniumPort)
        {
            Driver = new DefaultSelenium(seleniumHost, seleniumPort, "*firefox", hostName);
            Driver.Start();
            Driver.Open(hostPage);
        }

        public void SelectWindow(string window)
        {
            Driver.SelectWindow(window);
        }

        public void CloseWindow()
        {
            Driver.Close();
        }

        public MenuFixture Menu(string name)
        {
            return new MenuFixture(Driver, name);
        }

        public MenuItemFixture MenuItem(string name)
        {
            return new MenuItemFixture(Driver, name);
        }

        public DialogFixture Dialog()
        {
            return new DialogFixture(Driver);
        }

        public YesNoDialogFixture YesNoDialog()
        {
            return new YesNoDialogFixture(Driver);
        }

        public TabPanelFixture Tabs(string id)
        {
            return new TabPanelFixture(Driver, id);
        }

        public GridFixture Grid(string name)
        {
            return new GridFixture(Driver, name);
        }

        public RadioFixture Radio(string id)
        {
            return new RadioFixture(Driver, new ExtComponentPath(id));
        }

        public ButtonFixture Button(string id)
        {
            return new ButtonFixture(Driver, new ExtComponentPath(id));
        }

        public SplitButtonFixture SplitButton(string id)
        {
            return new SplitButtonFixture(Driver, new ExtComponentPath(id));
        }


        public TextFieldFixture TextField(string id)
        {
            return new TextFieldFixture(Driver, new ExtComponentPath(id));
        }

        public TextAreaFixture TextArea(string id)
        {
            return new TextAreaFixture(Driver, new ExtComponentPath(id));
        }

        public FieldSetFixture FieldSet(string id)
        {
            return new FieldSetFixture(Driver, new ExtComponentPath(id));
        }

        public ComboBoxFixture ComboBox(string id)
        {
            return new ComboBoxFixture(Driver, new ExtComponentPath(id));
        }

        public FrameFixture Frame(int index)
        {
            return new FrameFixture(Driver, index);
        }

        public SearchFieldFixture SearchField(string id)
        {
            return new SearchFieldFixture(Driver, new ExtComponentPath(id));
        }

        public DateFieldFixture DateField(string id)
        {
            return new DateFieldFixture(Driver, new ExtComponentPath(id));
        }

        public TreePanelFixture TreePanel(string name)
        {
            return new TreePanelFixture(Driver, new ExtComponentPath(name));
        }


        public CheckBoxFixture CheckBox(string name)
        {
            return new CheckBoxFixture(Driver, new ExtComponentPath(name));
        }

        public ExtComponentFixture Component(string plainPath)
        {
            return new ExtComponentFixture(Driver, new PlainPath(plainPath));
        }

    }
}
